<template>
	<div class="tt">
		<h1>发货</h1>
		<div>
			<div v-for="item in piclist" class="ovo">
				<img :src="`${$ip}/api/public/showimg/${item.book.pic}`" min-width="70" height="70" />
				<h5>书名:{{item.book.name}}</h5>
				<h5>数量:{{item.num}}</h5>
				<h5>单价:{{item.price}}</h5>
				<h5>库存:{{item.book.stock}}</h5>
			</div>

		</div>
		<div style="display: flex; margin-left: 45%;">
			<h5>账号:{{user.user.account}}</h5>
			<h5>电话:{{user.ship2phone}}</h5>
			<h5>下单:{{user.ship2name}}</h5>
		</div>
		<el-button @click="go()">发货</el-button>
		<el-dialog :visible.sync="dialogVisible" width="30%" :before-close="handleClose">
			<el-form label-width="80px">
				<el-form-item label="快递单 :">
					<el-input v-model="shipqh"></el-input>
				</el-form-item>
				<el-form-item label="快递公司:">
					<el-input v-model="shipgs"></el-input>
				</el-form-item>
			</el-form>

			<span slot="footer" class="dialog-footer">
				<el-button type="primary" @click="add(user.ordid)">保存</el-button>

			</span>
		</el-dialog>
	</div>
</template>

<script>
	export default {
		name: "flyorder",
		data() {
			return {
				user: {},
				piclist: [],
				list: [],
				dialogVisible: false,
				shipqh: 202401070000,
				shipgs: ''
			}
		},
		methods: {
			go() {
				this.shipqh = this.shipqh + this.user.ordid;
				console.log(this.shipqh);
				this.dialogVisible = true;

			},
			add(t) {
				console.log(t);
				let k = {
					shipno: this.shipqh,
					shipper: this.shipgs
				};
				this.$postkv('/api/adm/ord/updateShip/' + this.user.ordid, k).then((resp) => {
					console.log(resp.data.data);
					this.$message({
						showClose: true,
						message: '发货成功'
					});
				})
			},
			handleClose(done) {
				this.$confirm('确认关闭？')
					.then(_ => {
						done();
					})
					.catch(_ => {});
			},


		},
		mounted() {
			this.user = this.$route.query.name;
			for (let i in this.user.items) {
				// console.log("图片"+this.user.items[i].book.pic);
				this.piclist.push(this.user.items[i]);

			}

			/* this.piclist.push(this.user.user[i]); */
			/* 	console.log("账号" + this.user.user.account); */
			console.log("电话" + this.user.ship2phone);
		}
	}
</script>

<style>
	.tt {
		width: 80%;
		margin-top: 1%;
		text-align: center;
		font-size: 20px;
		font-family: KaiTi;
	}

	.tt button {
		margin-top: 20px;
	}

	.tt img {
		margin-top: 20px;
		width: 120px;
		height: 120px;
		position: relative;
		left: -300px;
		top: 30px
	}

	.ovo h5 {
		position: relative;
		top: -90px;
	}
</style>